﻿using System;
using UnityEngine;

// Token: 0x02000137 RID: 311
[DisallowMultipleComponent]
[AddComponentMenu("RVP/C#/Hover/Hover Motor", 0)]
public class HoverMotor : Motor
{
	// Token: 0x060005AA RID: 1450 RVA: 0x0002CAE8 File Offset: 0x0002ACE8
	public override void FixedUpdate()
	{
		base.FixedUpdate();
		float f = (!this.vp.brakeIsReverse) ? this.vp.accelInput : (this.vp.accelInput - this.vp.brakeInput);
		this.actualInput = this.inputCurve.Evaluate(Mathf.Abs(f)) * Mathf.Sign(f);
		foreach (HoverWheel hoverWheel in this.wheels)
		{
			if (this.ignition)
			{
				float num = this.boostPowerCurve.Evaluate(Mathf.Abs(this.vp.localVelocity.z));
				hoverWheel.targetSpeed = this.actualInput * this.forceCurve.keys[this.forceCurve.keys.Length - 1].time * ((!this.boosting) ? 1f : (1f + num));
				hoverWheel.targetForce = Mathf.Abs(this.actualInput) * this.forceCurve.Evaluate(Mathf.Abs(this.vp.localVelocity.z) - ((!this.boosting) ? 0f : num)) * this.power * ((!this.boosting) ? 1f : (1f + num)) * this.health;
			}
			else
			{
				hoverWheel.targetSpeed = 0f;
				hoverWheel.targetForce = 0f;
			}
			hoverWheel.doFloat = (this.ignition && this.health > 0f);
		}
	}

	// Token: 0x060005AB RID: 1451 RVA: 0x0002CCA0 File Offset: 0x0002AEA0
	public override void Update()
	{
		if (this.snd && this.ignition)
		{
			this.targetPitch = Mathf.Max(Mathf.Abs(this.actualInput), Mathf.Abs(this.vp.steerInput) * 0.5f) * (1f - this.forceCurve.Evaluate(Mathf.Abs(this.vp.localVelocity.z)));
		}
		base.Update();
	}

	// Token: 0x0400081A RID: 2074
	[Tooltip("Curve which calculates the driving force based on the speed of the vehicle, x-axis = speed, y-axis = force")]
	[Header("Performance")]
	public AnimationCurve forceCurve = AnimationCurve.EaseInOut(0f, 1f, 50f, 0f);

	// Token: 0x0400081B RID: 2075
	public HoverWheel[] wheels;
}
